<?php
/**
 * @version		$Id: countries.php 3 2011-12-16 20:19:15Z netix.mail@gmail.com $
 * @package		ALM Hoster
 * @desription	Web hosting and domain menager for resellers
 * @subpackage	Components
 * @copyright	Copyright (C) 2011 ALM Studio. All rights reserved.
 * @author		ALM Studio
 * @email		info@alm-studio.net
 * @link		http://alm-studio.net
 * @license		Commercial
 */

// No direct access to this file
defined('_JEXEC') or die;

jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');


class JFormFieldCountries extends JFormFieldList
{
	
	
	protected $type = 'Countries';

	protected function getOptions() 
	{
		$options = array();
		
		$db		= JFactory::getDbo();
		$query	= $db->getQuery(true);
		$query->select('CountryId AS value, CountryName AS text');
		$query->from('#__almh_countries');
		$query->order('CountryName ASC');
		$db->setQuery($query);

		$options = $db->loadObjectList();

		if ($db->getErrorNum()) {
			JError::raiseWarning(500, $db->getErrorMsg());
		}

		array_unshift($options, JHtml::_('select.option', '0', JText::_('COM_ALMHOSTER_COUNTRY_SELECT_LIST')));

		return $options;
	}
}
